﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:params="http://schemas.codeplex.com/elysium/params">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="{x:Type ScrollViewer}" Style.TargetType="{x:Type ScrollViewer}" >
        <Setter Property="Background" Value="{StaticResource BackgroundBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource MiddleLightBrush}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.TextFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="Normal" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="HorizontalContentAlignment" Value="Stretch" />
        <Setter Property="VerticalContentAlignment" Value="Stretch" />
        <Setter Property="Padding" Value="0" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Border Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}" 
                            TextBlock.FontSize="{TemplateBinding FontSize}" 
                            TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                            TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                            TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*" />
                                <ColumnDefinition Width="Auto" />
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*" />
                                <RowDefinition Height="Auto" />
                            </Grid.RowDefinitions>
                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" 
                                                    Grid.Column="0" 
                                                    Grid.Row="0" 
                                                    Content="{TemplateBinding Content}" 
                                                    ContentTemplate="{TemplateBinding ContentTemplate}" 
                                                    CanContentScroll="{TemplateBinding CanContentScroll}" 
                                                    CanHorizontallyScroll="False" 
                                                    CanVerticallyScroll="False" 
                                                    Margin="{TemplateBinding Padding}" />
                            <ScrollBar x:Name="PART_HorizontalScrollBar" 
                                       Grid.Column="0" 
                                       Grid.Row="1" 
                                       AutomationProperties.AutomationId="HorizontalScrollBar" 
                                       Cursor="Arrow" 
                                       Orientation="Horizontal" 
                                       Minimum="0" 
                                       Maximum="{TemplateBinding ScrollableWidth}" 
                                       Value="{TemplateBinding HorizontalOffset}" 
                                       ViewportSize="{TemplateBinding ViewportWidth}" 
                                       Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" />
                            <ScrollBar x:Name="PART_VerticalScrollBar" 
                                       Grid.Column="1" 
                                       Grid.Row="0" 
                                       AutomationProperties.AutomationId="VerticalScrollBar" 
                                       Cursor="Arrow" 
                                       Orientation="Vertical" 
                                       Minimum="0" 
                                       Maximum="{TemplateBinding ScrollableHeight}" 
                                       Value="{TemplateBinding VerticalOffset}" 
                                       ViewportSize="{TemplateBinding ViewportHeight}" 
                                       Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" />
                        </Grid>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>